package com.xuecheng.teaching.controller;

import com.xuecheng.commons.model.vo.CourseWorkRecVo;
import com.xuecheng.commons.model.vo.ResponseResult;
import com.xuecheng.commons.utils.BeanHelper;
import com.xuecheng.teaching.domain.CourseWorkRec;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.xuecheng.teaching.service.CourseWorkRecService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author itheima
 */
@Slf4j
@RestController
public class CourseWorkRecController {

    @Autowired
    private CourseWorkRecService  courseWorkRecService;

    //根据课程发布id获取课程作业统计表
    @GetMapping("/coursework")
    public ResponseResult<CourseWorkRecVo> findIdByPubId(@RequestParam Long coursePubId){
        CourseWorkRec courseWorkRec = courseWorkRecService.lambdaQuery().eq(CourseWorkRec::getCoursePubId, coursePubId).one();
        CourseWorkRecVo courseWorkRecVo = BeanHelper.copyProperties(courseWorkRec, CourseWorkRecVo.class);
        return ResponseResult.okResult(courseWorkRecVo);
    }
}
